<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magento.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magento.com for more information.
 *
 * @category    design
 * @package     base_default
 * @copyright   Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<?php
/**
 * Template for Sf_AutoCoupon_View
*email 邮箱
*events_code  活动编码 
*rule_id  规则id
*/

//配置项
$coupon_url = $this->getBaseUrl()."autocoupon/new/sendEmailCoupon/";
$rule_id    = array('27','28','29');
?>
<!DOCTYPE html>

</head>
<body>
	<div class="pack_promo">
		<div class="pack_promo_img"></div>
		<div class="pack_promo_content">
			<div><p>Получи купоны на 9$ на покупку на сайте <a href="<?php echo $this->getBaseUrl() ?>" > Rumall.com</a></p></div>
			<div class="pack_promo_form">
				<form action="<?php echo $coupon_url ?>" method="post" id="pack_promo">
					<div class="input-box">
						<input type="email" autocapitalize="off" autocorrect="off" spellcheck="false" name="email" id="vibeitest_promote_email" title="<?php echo Mage::helper('core')->quoteEscape($this->__('ign up for Discounts')) ?>" class="input-text required-entry validate-email" />
					</div>
					<div class="actions">
						<button type="submit" title="<?php echo $this->__('Subscribe') ?>" class="button"><span><span><?php echo $this->__('Получить купон') ?></span></span></button>
					</div>
					<div class="input-boxs">
						<input type="checkbox" value="1" checked name='checkbox'> Я принимаю условия <a target="_Blank" href="<?php echo $this->getBaseUrl() ?>privacy-policy/"> Политики конфиденциальности </a> и <a target="_Blank" href="<?php echo $this->getBaseUrl() ?>terms-conditions/"> Условия Продажи </a> сайта Rumall.com
					</div>
					<div>
						<span id="vibeitest_promote_box" style="margin-left:5px;"></span>
					</div>
				</form>
			</div>
		</div>
	</div>
<script type="text/javascript">
 //<![CDATA[
	(function($){
		$('.em-header-bottom.em-fixed-top').css("display","none");
		$('#pack_promo').submit(function(){
			var email       = $("#vibeitest_promote_email").val();
			var events_code = 'pack_promo';
			var rule_id     = <?php echo json_encode($rule_id); ?>;
			var view_url    =  $("#pack_promo").attr("action");
			console.log(view_url);
			if($('#pack_promo input[name=checkbox]').is(':checked')) {
				if(email && events_code && rule_id ){
					$("#vibeitest_promote_box").html('<img src="<?php echo $this->getSkinUrl('images/ajax-review.jpg');?>">');
					$.post(view_url,{"email":email,events_code:events_code,rule_id:rule_id},function(data){
						if(data == 'success'){
			                $("#vibeitest_promote_box").css("color","#434343");
							$("#vibeitest_promote_box").html('Ура! Ваши купоны были отправлены на ваш email!');					
							CountDown(); 
						}else{
			                $("#vibeitest_promote_box").css("color","#e33e3e");
							$("#vibeitest_promote_box").html('Приносим извинения, акция уже закончилась. Заходите на <a href="<?php echo $this->getBaseUrl() ?>" > Rumall.com</a>, тут всегда много интересного.');
						}
					},"json" );
				}
			}
			var countdown = 5;
			function CountDown(){  
			    if(countdown==0){  
			       window.location.href = "<?php echo $this->getBaseUrl(); ?>";
			    }else{                    
			        setTimeout(function(){  
			            countdown--;  
			            CountDown();  
			        },1000)  
			    }  
			} 
			return false;
		})
	})(jQuery);
//]]> 
</script>

</body>
</html>

	
